﻿using MediatR;
using Microsoft.AspNetCore.Mvc;
using RedDragon.Common.Dtos;
using RedDragon.ERP.API.Application.Commands.ProductionTasks;
using T.Common.Domain.Common;

namespace RedDragon.ERP.API.Controllers
{
    /// <summary>
    /// 生产任务控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ProductionTasksController : ControllerBase
    {
        private readonly IMediator mediator;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="mediator"></param>
        public ProductionTasksController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 生产任务添加
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result> CreateProductionTasks(CreateProductionTasksCommand cmd)
        {
            return await mediator.Send(cmd);
        }
        /// <summary>
        /// 生产任务显示查询列表
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Result<List<ProductionTasksDto>>> SearchProductionTasks([FromQuery] SearchProductionTasksCommand cmd)
        {
            return await mediator.Send(cmd);
        }
        /// <summary>
        /// 任务类型显示列表
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Result> SearchTaskType([FromQuery] SearchTaskTypeCommand cmd)
        {
            return await mediator.Send(cmd);
        }
        /// <summary>
        /// 生产任务删除
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<Result> DeleteProductionTasks(DeleteProductionTasksCommand cmd)
        {
            return await mediator.Send(cmd);
        }
        /// <summary>
        /// 根据生产任务ID进行查询
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Result<ProductionTasksDto>> SearchProductionTasksID([FromQuery] SearchProductionTasksIDCommand cmd)
        {
            return await mediator.Send(cmd);
        }
        /// <summary>
        /// 生产任务修改
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<Result> UpdateProductionTasks(UpdateProductionTasksCommand cmd)
        {
            return await mediator.Send(cmd);
        }
        /// <summary>
        /// 生产任务的审批
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<Result> UpdAuditStatus(UpdAuditStatusCommand cmd)
        {
            return await mediator.Send(cmd);
        }
    }
}
